import services from '@/services';
const state = {
  refreshPro: true, //是否刷新结算单
  commentInfo: null, //评价商品信息
  orderListRefre: false, //是否刷新订单列表
}

const mutations = {
  setRefreshPro(state, data) {
    state.refreshPro = data;
  },
  setCommentInfo(state, data) {
    state.commentInfo = data;
  },
  setOrderListRefre(state, data) {
    state.orderListRefre = data;
  },
}

const actions = {
  //订单预览，结算时预览
  async orderPreset(store, params) {
    const {
      data
    } = await services.order.orderPreset(params);
    return data;
  },
  //订单创建
  async orderCreate(store, params) {
    const {
      data
    } = await services.order.orderCreate(params);
    return data;
  },
  //订单创建
  async orderCreateNl(store, params) {
    const {
      data
    } = await services.order.orderCreateNl(params);
    return data;
  },
  //订单关闭
  async orderClose(store, params) {
    const {
      data
    } = await services.order.orderClose(params);
    return data;
  },
  //查询我的订单列表
  async orderList(store, params) {
    const {
      data
    } = await services.order.orderList(params);
    return data;
  },
  //查询我的订单详情
  async orderInfo(store, params) {
    const {
      data
    } = await services.order.orderInfo(params);
    return data;
  },
  //订单支付跳转第三方
  async orderTopay(store, params) {
    const {
      data
    } = await services.order.orderTopay(params);
    return data;
  },
  //第三方支付回调
  async orderPaycallback(store, params) {
    const {
      data
    } = await services.order.orderPaycallback(params);
    return data;
  },
  //确认收货
  async orderConfirm(store, params) {
    const {
      data
    } = await services.order.orderConfirm(params);
    return data;
  },
  //订单评价
  async orderComment(store, params) {
    const {
      data
    } = await services.order.orderComment(params);
    return data;
  },
  //立即支付订单
  async orderPay(store, params) {
    const {
      data
    } = await services.order.orderPay(params);
    return data;
  },
}

const getters = {

}

export default {
  namespaced: true,
  state,
  mutations,
  actions,
}
